# Drone git push setup for Codeberg.org

Drone CI yaml example on how to push to git repo after build is done.

In my case I created the key with [something like](https://stackoverflow.com/a/59515175): `ssh-keygen -m PEM -t rsa -P "" -C "your_email@example.com" -f ~/.ssh/id_john_codeberg`. Otherwise `drone-git-push` fails to push.

## Instructions

[Setup](https://notabug.org/adnan360/droney) a Drone CI instance on any computer in the world, without VPS or domains! Or use any existing instance you have.

Run `ssh-keygen -m PEM -t rsa -P "" -C "your_email@example.com" -f ~/.ssh/id_john_codeberg`.

Login to Codeberg, (Avatar) - Settings - SSH/GPG Keys - Add Key. Paste in the output of `cat ~/.ssh/id_john_codeberg.pub` and click Add Key.

Open Drone CI UI URL, make sure to activate the repo. Go inside repo - Settings - Secrets - New Secret. Create a new secret with name as `ssh_key` and put `cat ~/.ssh/id_john_codeberg | awk '{printf "%s\\n", $0}'` as value. The `awk` call is for replacing new lines with literal `\n` as [this issue](https://github.com/appleboy/drone-git-push/issues/34#issuecomment-523610284) suggests.

Now commit the `.drone.yml` file from this directory in the repo root (change the placeholder values) and it should run the build process. It will run the build and (if there is a change in output) it will commit the changes automatically with commit message `Drone build (some hash)`.

## Placeholder values

`johndoe456` is codeberg.org username, `pages.git` is the repo. `author_name` and `author_email` are related to commit.
